/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.jsysacc.asistencia.view.gui.principal;

import com.jsysacc.asistencia.model.logic.maestros.ParametroLogic;
import com.jsysacc.asistencia.view.gui.asistencia.FormDialogControlAsistencias;
import com.jsysacc.asistencia.view.gui.asistencia.FormDialogPermisosPorDia;
import com.jsysacc.asistencia.view.gui.asistencia.FormDialogRegistroAsistencia;
import com.jsysacc.asistencia.view.gui.maestros.FormDialogListArea;
import com.jsysacc.asistencia.view.gui.maestros.FormDialogListCargo;
import com.jsysacc.asistencia.view.gui.maestros.FormDialogListDiaFeriado;
import com.jsysacc.asistencia.view.gui.maestros.FormDialogListHorario;
import com.jsysacc.asistencia.view.gui.maestros.FormDialogListPersonal;
import com.jsysacc.asistencia.view.gui.maestros.FormDialogListVia;
import com.jsysacc.asistencia.view.gui.maestros.FormDialogListZona;
import com.jsysacc.asistencia.view.gui.reportes.FormDialogRepAsistencias;
import com.jsysacc.asistencia.view.gui.reportes.FormDialogRepPermisos;
import com.jsysacc.asistencia.view.gui.seguridad.FormDialogInformacion;
import com.jsysacc.asistencia.view.gui.seguridad.FormDialogMantConfiguracion;
import com.jsysacc.asistencia.view.gui.seguridad.FormDialogMantProcesarPermisos;
import com.jsysacc.asistencia.view.resources.commons.ImagenFondoPrincipal;
import com.jsysacc.asistencia.view.resources.commons.JLogicInterfaz;
import java.awt.Image;
import java.awt.Toolkit;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.Calendar;
import java.util.Date;
import java.util.GregorianCalendar;
import javax.swing.UIManager;
import java.util.ResourceBundle;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.JOptionPane;
import org.joda.time.DateTime;

/**
 *
 * @author Carlos
 */
public class FormPrincipal extends javax.swing.JFrame implements Runnable, JLogicInterfaz {

    /**
     * Creates new form FormPrincipal
     */
    String hora, minutos, segundos, ampm, fecha;
    DateTime fechaSis;
    Thread h1;
    boolean empReg;
    boolean isLogin;
    ParametroLogic logic = new ParametroLogic();

    private final ResourceBundle rbMensajes = ResourceBundle.getBundle("com.jsysacc.asistencia.view.resources.commons.Mensajes");
    private final ResourceBundle rbMainMenu = ResourceBundle.getBundle("com.jsysacc.asistencia.view.resources.commons.MainMenu");

    public FormPrincipal() {
        initComponents();
        this.jdesktopPrincipal.setBorder(new ImagenFondoPrincipal());
        this.jformDialogLogin.setSize(350, 180);
        this.jformDialogLogin.setLocationRelativeTo(this);
        this.jformDialogLogin.setVisible(true);
        setExtendedState(this.getExtendedState() | this.MAXIMIZED_BOTH);
        initMaster();

    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jformDialogLogin = new javax.swing.JDialog();
        jbtnIniciarSesion = new javax.swing.JButton();
        jLabel1 = new javax.swing.JLabel();
        jLabel2 = new javax.swing.JLabel();
        jtxtUsuario = new javax.swing.JTextField();
        jLabel3 = new javax.swing.JLabel();
        jtxtClave = new javax.swing.JPasswordField();
        jPanel1 = new javax.swing.JPanel();
        jdesktopPrincipal = new javax.swing.JDesktopPane();
        jSeparator4 = new javax.swing.JToolBar.Separator();
        jtbarArriba = new javax.swing.JToolBar();
        jbmbarSalir = new javax.swing.JButton();
        jtbarAbajo = new javax.swing.JToolBar();
        jLabel10 = new javax.swing.JLabel();
        jPanel3 = new javax.swing.JPanel();
        jSeparator5 = new javax.swing.JSeparator();
        jLabel6 = new javax.swing.JLabel();
        jlblUsuarioPrincipal = new javax.swing.JLabel();
        jLabel5 = new javax.swing.JLabel();
        jlblEmpresaPrincipal = new javax.swing.JLabel();
        jSeparator6 = new javax.swing.JSeparator();
        jLabel7 = new javax.swing.JLabel();
        jlblFechaHoraPrincipal = new javax.swing.JLabel();
        jmenubarPrincipal = new javax.swing.JMenuBar();
        jmnMaestros = new javax.swing.JMenu();
        jmnPersonal = new javax.swing.JMenu();
        jmniPersonal = new javax.swing.JMenuItem();
        jSeparator3 = new javax.swing.JPopupMenu.Separator();
        jmniArea = new javax.swing.JMenuItem();
        jmniCargo = new javax.swing.JMenuItem();
        jmniHorario = new javax.swing.JMenuItem();
        jSeparator8 = new javax.swing.JPopupMenu.Separator();
        jmniZona = new javax.swing.JMenuItem();
        jmniVia = new javax.swing.JMenuItem();
        jmniDiaFeriado = new javax.swing.JMenuItem();
        jSeparator1 = new javax.swing.JPopupMenu.Separator();
        jmniSalir = new javax.swing.JMenuItem();
        jMenu1 = new javax.swing.JMenu();
        jmniControlAsistencia = new javax.swing.JMenuItem();
        jMenu2 = new javax.swing.JMenu();
        jMenuItem1 = new javax.swing.JMenuItem();
        jMenuItem2 = new javax.swing.JMenuItem();
        jmniInterfazAsistencia = new javax.swing.JMenuItem();
        jmnReportes = new javax.swing.JMenu();
        jmniRptAsistencias = new javax.swing.JMenuItem();
        jmniRptPermisosVacaciones = new javax.swing.JMenuItem();
        jmnOpciones = new javax.swing.JMenu();
        jmniConfiguracionGeneral = new javax.swing.JMenuItem();
        jmnSeguridad = new javax.swing.JMenu();
        jsmnRolesPermisos = new javax.swing.JMenu();
        jmniProcesarPermisos = new javax.swing.JMenuItem();
        jmniRoles = new javax.swing.JMenuItem();
        jsmnUsuariosClaves = new javax.swing.JMenu();
        jmniUsuarios = new javax.swing.JMenuItem();
        jmniCambioClave = new javax.swing.JMenuItem();
        jSeparator7 = new javax.swing.JPopupMenu.Separator();
        jmniAcercaSistema = new javax.swing.JMenuItem();

        jformDialogLogin.setTitle("Ingresar al Sistema JSYSACC");
        jformDialogLogin.setIconImage(getIconImage());
        jformDialogLogin.setName(""); // NOI18N
        jformDialogLogin.setResizable(false);
        jformDialogLogin.addWindowListener(new java.awt.event.WindowAdapter() {
            public void windowClosing(java.awt.event.WindowEvent evt) {
                jformDialogLoginWindowClosing(evt);
            }
        });

        jbtnIniciarSesion.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/jsysacc/asistencia/view/resources/icons/ok_login.png"))); // NOI18N
        jbtnIniciarSesion.setText("Iniciar Sesión");
        jbtnIniciarSesion.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jbtnIniciarSesionActionPerformed(evt);
            }
        });

        jLabel1.setText("Clave");

        jLabel2.setText("Usuario");

        jtxtUsuario.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jtxtUsuarioActionPerformed(evt);
            }
        });

        jLabel3.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/jsysacc/asistencia/view/resources/icons/login.png"))); // NOI18N
        jLabel3.setBorder(javax.swing.BorderFactory.createEtchedBorder());

        javax.swing.GroupLayout jformDialogLoginLayout = new javax.swing.GroupLayout(jformDialogLogin.getContentPane());
        jformDialogLogin.getContentPane().setLayout(jformDialogLoginLayout);
        jformDialogLoginLayout.setHorizontalGroup(
            jformDialogLoginLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jformDialogLoginLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jLabel3, javax.swing.GroupLayout.PREFERRED_SIZE, 113, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(18, 18, 18)
                .addGroup(jformDialogLoginLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(jbtnIniciarSesion)
                    .addGroup(jformDialogLoginLayout.createSequentialGroup()
                        .addGroup(jformDialogLoginLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jLabel2)
                            .addComponent(jLabel1))
                        .addGap(24, 24, 24)
                        .addGroup(jformDialogLoginLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                            .addComponent(jtxtUsuario)
                            .addComponent(jtxtClave, javax.swing.GroupLayout.DEFAULT_SIZE, 120, Short.MAX_VALUE))))
                .addContainerGap(29, Short.MAX_VALUE))
        );
        jformDialogLoginLayout.setVerticalGroup(
            jformDialogLoginLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jformDialogLoginLayout.createSequentialGroup()
                .addGap(35, 35, 35)
                .addGroup(jformDialogLoginLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jtxtUsuario, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel2))
                .addGap(18, 18, 18)
                .addGroup(jformDialogLoginLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel1)
                    .addComponent(jtxtClave, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(18, 18, 18)
                .addComponent(jbtnIniciarSesion)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
            .addGroup(jformDialogLoginLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jLabel3, javax.swing.GroupLayout.PREFERRED_SIZE, 0, Short.MAX_VALUE)
                .addContainerGap())
        );

        setDefaultCloseOperation(javax.swing.WindowConstants.DO_NOTHING_ON_CLOSE);
        setTitle("S I S T E MA  A S I S T E N C I A  J - S Y S A C C");
        setCursor(new java.awt.Cursor(java.awt.Cursor.DEFAULT_CURSOR));
        setIconImage(getIconImage());

        jdesktopPrincipal.setBackground(new java.awt.Color(191, 205, 219));
        jdesktopPrincipal.setBorder(javax.swing.BorderFactory.createEtchedBorder());

        javax.swing.GroupLayout jdesktopPrincipalLayout = new javax.swing.GroupLayout(jdesktopPrincipal);
        jdesktopPrincipal.setLayout(jdesktopPrincipalLayout);
        jdesktopPrincipalLayout.setHorizontalGroup(
            jdesktopPrincipalLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jdesktopPrincipalLayout.createSequentialGroup()
                .addGap(176, 176, 176)
                .addComponent(jSeparator4, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        jdesktopPrincipalLayout.setVerticalGroup(
            jdesktopPrincipalLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jdesktopPrincipalLayout.createSequentialGroup()
                .addContainerGap(93, Short.MAX_VALUE)
                .addComponent(jSeparator4, javax.swing.GroupLayout.PREFERRED_SIZE, 31, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(38, 38, 38))
        );
        jdesktopPrincipal.setLayer(jSeparator4, javax.swing.JLayeredPane.DEFAULT_LAYER);

        jtbarArriba.setBorder(javax.swing.BorderFactory.createEtchedBorder());
        jtbarArriba.setFloatable(false);

        jbmbarSalir.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/jsysacc/asistencia/view/resources/icons/px_24_24/btn_salir_24.png"))); // NOI18N
        jbmbarSalir.setToolTipText("Salir");
        jbmbarSalir.setFocusable(false);
        jbmbarSalir.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        jbmbarSalir.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        jbmbarSalir.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jbmbarSalirActionPerformed(evt);
            }
        });
        jtbarArriba.add(jbmbarSalir);

        jtbarAbajo.setBorder(javax.swing.BorderFactory.createEtchedBorder());
        jtbarAbajo.setFloatable(false);
        jtbarAbajo.setToolTipText("");
        jtbarAbajo.add(jLabel10);

        jSeparator5.setOrientation(javax.swing.SwingConstants.VERTICAL);

        jLabel6.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N
        jLabel6.setText("USUARIO:");

        jLabel5.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N
        jLabel5.setText("EMPRESA:");

        jSeparator6.setOrientation(javax.swing.SwingConstants.VERTICAL);

        jLabel7.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N
        jLabel7.setText("FECHA Y HORA:");

        jlblFechaHoraPrincipal.setFont(new java.awt.Font("OCR A Extended", 0, 13)); // NOI18N

        javax.swing.GroupLayout jPanel3Layout = new javax.swing.GroupLayout(jPanel3);
        jPanel3.setLayout(jPanel3Layout);
        jPanel3Layout.setHorizontalGroup(
            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel3Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jLabel6)
                .addGap(18, 18, 18)
                .addComponent(jlblUsuarioPrincipal, javax.swing.GroupLayout.PREFERRED_SIZE, 100, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(18, 18, 18)
                .addComponent(jSeparator5, javax.swing.GroupLayout.PREFERRED_SIZE, 17, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jLabel5)
                .addGap(18, 18, 18)
                .addComponent(jlblEmpresaPrincipal, javax.swing.GroupLayout.PREFERRED_SIZE, 240, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(18, 18, 18)
                .addComponent(jSeparator6, javax.swing.GroupLayout.PREFERRED_SIZE, 17, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 179, Short.MAX_VALUE)
                .addComponent(jLabel7)
                .addGap(18, 18, 18)
                .addComponent(jlblFechaHoraPrincipal, javax.swing.GroupLayout.PREFERRED_SIZE, 454, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap())
        );
        jPanel3Layout.setVerticalGroup(
            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jSeparator5)
            .addComponent(jSeparator6)
            .addGroup(jPanel3Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jlblFechaHoraPrincipal, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(jlblUsuarioPrincipal, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel3Layout.createSequentialGroup()
                        .addGap(0, 0, Short.MAX_VALUE)
                        .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jLabel5, javax.swing.GroupLayout.Alignment.TRAILING)
                            .addComponent(jlblEmpresaPrincipal, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.PREFERRED_SIZE, 14, javax.swing.GroupLayout.PREFERRED_SIZE)))
                    .addComponent(jLabel6)
                    .addComponent(jLabel7))
                .addContainerGap())
        );

        jtbarAbajo.add(jPanel3);

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jdesktopPrincipal)
            .addComponent(jtbarAbajo, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
            .addComponent(jtbarArriba, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addComponent(jtbarArriba, javax.swing.GroupLayout.PREFERRED_SIZE, 35, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(0, 0, 0)
                .addComponent(jdesktopPrincipal)
                .addGap(0, 0, 0)
                .addComponent(jtbarAbajo, javax.swing.GroupLayout.PREFERRED_SIZE, 35, javax.swing.GroupLayout.PREFERRED_SIZE))
        );

        jmnMaestros.setText("Maestros");
        jmnMaestros.setName("MAPE_0000_0000_0000"); // NOI18N

        jmnPersonal.setText("Personal");
        jmnPersonal.setName("MAPE_PERS_0000_0000"); // NOI18N

        jmniPersonal.setText("Personal");
        jmniPersonal.setName("MAPE_PERS_PERS_0000"); // NOI18N
        jmniPersonal.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jmniPersonalActionPerformed(evt);
            }
        });
        jmnPersonal.add(jmniPersonal);
        jmnPersonal.add(jSeparator3);

        jmniArea.setText("Áreas");
        jmniArea.setName("MAPE_PERS_AREA_0000"); // NOI18N
        jmniArea.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jmniAreaActionPerformed(evt);
            }
        });
        jmnPersonal.add(jmniArea);

        jmniCargo.setText("Cargos");
        jmniCargo.setName("MAPE_PERS_CARG_0000"); // NOI18N
        jmniCargo.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jmniCargoActionPerformed(evt);
            }
        });
        jmnPersonal.add(jmniCargo);

        jmniHorario.setText("Horarios");
        jmniHorario.setName("MAPE_PERS_HORA_0000"); // NOI18N
        jmniHorario.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jmniHorarioActionPerformed(evt);
            }
        });
        jmnPersonal.add(jmniHorario);
        jmnPersonal.add(jSeparator8);

        jmniZona.setText("Zonas");
        jmniZona.setName("MAPE_UBIG_ZONA_0000"); // NOI18N
        jmniZona.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jmniZonaActionPerformed(evt);
            }
        });
        jmnPersonal.add(jmniZona);

        jmniVia.setText("Vías");
        jmniVia.setName("MAPE_UBIG_VIAS_0000"); // NOI18N
        jmniVia.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jmniViaActionPerformed(evt);
            }
        });
        jmnPersonal.add(jmniVia);

        jmnMaestros.add(jmnPersonal);

        jmniDiaFeriado.setText("Día Feriado");
        jmniDiaFeriado.setName("MAPE_DIFE_0000_0000"); // NOI18N
        jmniDiaFeriado.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jmniDiaFeriadoActionPerformed(evt);
            }
        });
        jmnMaestros.add(jmniDiaFeriado);
        jmnMaestros.add(jSeparator1);

        jmniSalir.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/jsysacc/asistencia/view/resources/icons/px_16_16/salir.png"))); // NOI18N
        jmniSalir.setText("Salir");
        jmniSalir.setName("MAPE_SALI_0000_0000"); // NOI18N
        jmniSalir.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jmniSalirActionPerformed(evt);
            }
        });
        jmnMaestros.add(jmniSalir);

        jmenubarPrincipal.add(jmnMaestros);

        jMenu1.setText("Asistencia");
        jMenu1.setName("MASI_0000_0000_0000"); // NOI18N

        jmniControlAsistencia.setText("Control de Asistencia");
        jmniControlAsistencia.setName("MASI_CTAS_0000_0000"); // NOI18N
        jmniControlAsistencia.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jmniControlAsistenciaActionPerformed(evt);
            }
        });
        jMenu1.add(jmniControlAsistencia);

        jMenu2.setText("Control de Permisos / Vacaciones");

        jMenuItem1.setText("Registro de Perm./Vac. por Días");
        jMenuItem1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItem1ActionPerformed(evt);
            }
        });
        jMenu2.add(jMenuItem1);

        jMenuItem2.setText("Registro de Perm./Vac. por Horas");
        jMenu2.add(jMenuItem2);

        jMenu1.add(jMenu2);

        jmniInterfazAsistencia.setText("Interfaz de Asistencia");
        jmniInterfazAsistencia.setName("MASI_INAS_0000_0000"); // NOI18N
        jmniInterfazAsistencia.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jmniInterfazAsistenciaActionPerformed(evt);
            }
        });
        jMenu1.add(jmniInterfazAsistencia);

        jmenubarPrincipal.add(jMenu1);

        jmnReportes.setText("Reportes");
        jmnReportes.setName("MREP_0000_0000_0000"); // NOI18N

        jmniRptAsistencias.setText("Asistencias");
        jmniRptAsistencias.setName("MREP_RASI_0000_0000"); // NOI18N
        jmniRptAsistencias.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jmniRptAsistenciasActionPerformed(evt);
            }
        });
        jmnReportes.add(jmniRptAsistencias);

        jmniRptPermisosVacaciones.setText("Permisos");
        jmniRptPermisosVacaciones.setName("MREP_RPER_0000_0000"); // NOI18N
        jmniRptPermisosVacaciones.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jmniRptPermisosVacacionesActionPerformed(evt);
            }
        });
        jmnReportes.add(jmniRptPermisosVacaciones);

        jmenubarPrincipal.add(jmnReportes);

        jmnOpciones.setText("Opciones");
        jmnOpciones.setName("MOPC_0000_0000_0000"); // NOI18N

        jmniConfiguracionGeneral.setText("Configuración General");
        jmniConfiguracionGeneral.setName("MOPC_COGE_0000_0000"); // NOI18N
        jmniConfiguracionGeneral.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jmniConfiguracionGeneralActionPerformed(evt);
            }
        });
        jmnOpciones.add(jmniConfiguracionGeneral);

        jmenubarPrincipal.add(jmnOpciones);

        jmnSeguridad.setText("Seguridad");
        jmnSeguridad.setName("MSEG_0000_0000_0000"); // NOI18N

        jsmnRolesPermisos.setText("Roles y Permisos");
        jsmnRolesPermisos.setName("MSEG_ROPE_0000_0000"); // NOI18N

        jmniProcesarPermisos.setText("Procesar Permisos");
        jmniProcesarPermisos.setName("MSEG_ROPE_PRPE_0000"); // NOI18N
        jmniProcesarPermisos.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jmniProcesarPermisosActionPerformed(evt);
            }
        });
        jsmnRolesPermisos.add(jmniProcesarPermisos);

        jmniRoles.setText("Roles");
        jmniRoles.setName("MSEG_ROPE_ROLE_0000"); // NOI18N
        jmniRoles.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jmniRolesActionPerformed(evt);
            }
        });
        jsmnRolesPermisos.add(jmniRoles);

        jmnSeguridad.add(jsmnRolesPermisos);

        jsmnUsuariosClaves.setText("Usuarios y Claves");
        jsmnUsuariosClaves.setName("MSEG_USCL_0000_0000"); // NOI18N

        jmniUsuarios.setText("Usuarios");
        jmniUsuarios.setName("MSEG_USCL_USUA_0000"); // NOI18N
        jsmnUsuariosClaves.add(jmniUsuarios);

        jmniCambioClave.setText("Cambio de Clave");
        jmniCambioClave.setName("MSEG_USCL_CACL_0000"); // NOI18N
        jsmnUsuariosClaves.add(jmniCambioClave);

        jmnSeguridad.add(jsmnUsuariosClaves);
        jmnSeguridad.add(jSeparator7);

        jmniAcercaSistema.setText("Acerca de J - S Y S A C C");
        jmniAcercaSistema.setName("MSEG_ASIS_0000_0000"); // NOI18N
        jmniAcercaSistema.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jmniAcercaSistemaActionPerformed(evt);
            }
        });
        jmnSeguridad.add(jmniAcercaSistema);

        jmenubarPrincipal.add(jmnSeguridad);

        setJMenuBar(jmenubarPrincipal);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
        );

        getAccessibleContext().setAccessibleName("S I S T E MA  C O M E R C I A L  JSYSACC");

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void jformDialogLoginWindowClosing(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_jformDialogLoginWindowClosing
        // TODO add your handling code here:
        System.exit(0);
    }//GEN-LAST:event_jformDialogLoginWindowClosing

    private void jbtnIniciarSesionActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jbtnIniciarSesionActionPerformed
        // TODO add your handling code here:
        this.setVisible(true);
        this.jformDialogLogin.setVisible(false);
        this.isLogin = true;
    }//GEN-LAST:event_jbtnIniciarSesionActionPerformed

    private void jbmbarSalirActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jbmbarSalirActionPerformed
        // TODO add your handling code here:
        int rpta;
        rpta = JOptionPane.showConfirmDialog(this, rbMensajes.getString("MSG_SAL_SIS"), rbMainMenu.getString("MEN_PRI"), JOptionPane.YES_NO_OPTION, JOptionPane.INFORMATION_MESSAGE);
        if (rpta == 0) {
            System.exit(0);
        }
    }//GEN-LAST:event_jbmbarSalirActionPerformed

    private void jmniSalirActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jmniSalirActionPerformed
        // TODO add your handling code here:
        int rpta;
        rpta = JOptionPane.showConfirmDialog(this, rbMensajes.getString("MSG_SAL_SIS"), rbMainMenu.getString("MEN_PRI"), JOptionPane.YES_NO_OPTION, JOptionPane.INFORMATION_MESSAGE);
        if (rpta == 0) {
            System.exit(0);
        }
    }//GEN-LAST:event_jmniSalirActionPerformed

    private void jmniPersonalActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jmniPersonalActionPerformed
        // TODO add your handling code here:
        FormDialogListPersonal oFormDialogListPersonal = new FormDialogListPersonal(this, true);
        oFormDialogListPersonal.setLocationRelativeTo(this);
        oFormDialogListPersonal.setTitle(rbMainMenu.getString("SUB_MEN_LIS_PERS"));
        oFormDialogListPersonal.setVisible(true);
    }//GEN-LAST:event_jmniPersonalActionPerformed

    private void jmniInterfazAsistenciaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jmniInterfazAsistenciaActionPerformed
        // TODO add your handling code here:
        FormDialogRegistroAsistencia oFormDialogRegistroAsistencia = new FormDialogRegistroAsistencia(this, true);
        oFormDialogRegistroAsistencia.setLocationRelativeTo(this);
        oFormDialogRegistroAsistencia.setVisible(true);
    }//GEN-LAST:event_jmniInterfazAsistenciaActionPerformed

    private void jmniZonaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jmniZonaActionPerformed
        // TODO add your handling code here:
        FormDialogListZona oFormDialogListZona = new FormDialogListZona(this, true);
        oFormDialogListZona.setLocationRelativeTo(this);
        oFormDialogListZona.setTitle(rbMainMenu.getString("SUB_MEN_LIS_ZONA"));
        oFormDialogListZona.setVisible(true);
    }//GEN-LAST:event_jmniZonaActionPerformed

    private void jmniDiaFeriadoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jmniDiaFeriadoActionPerformed
        // TODO add your handling code here:
        FormDialogListDiaFeriado oFormDialogListDiaFeriado = new FormDialogListDiaFeriado(this, true);
        oFormDialogListDiaFeriado.setLocationRelativeTo(this);
        oFormDialogListDiaFeriado.setTitle(rbMainMenu.getString("SUB_MEN_LIS_DIAF"));
        oFormDialogListDiaFeriado.setVisible(true);
    }//GEN-LAST:event_jmniDiaFeriadoActionPerformed

    private void jmniHorarioActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jmniHorarioActionPerformed
        // TODO add your handling code here:
        FormDialogListHorario oFormDialogListHorario = new FormDialogListHorario(this, true);
        oFormDialogListHorario.setLocationRelativeTo(this);
        oFormDialogListHorario.setTitle(rbMainMenu.getString("SUB_MEN_LIS_HORARIO"));
        oFormDialogListHorario.setVisible(true);
    }//GEN-LAST:event_jmniHorarioActionPerformed

    private void jmniAreaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jmniAreaActionPerformed
        // TODO add your handling code here:
        FormDialogListArea oFormDialogListArea = new FormDialogListArea(this, true);
        oFormDialogListArea.setLocationRelativeTo(this);
        oFormDialogListArea.setTitle(rbMainMenu.getString("SUB_MEN_LIS_AREA"));
        oFormDialogListArea.setVisible(true);
    }//GEN-LAST:event_jmniAreaActionPerformed

    private void jmniViaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jmniViaActionPerformed
        // TODO add your handling code here:
        FormDialogListVia oFormDialogListVia = new FormDialogListVia(this, true);
        oFormDialogListVia.setLocationRelativeTo(this);
        oFormDialogListVia.setTitle(rbMainMenu.getString("SUB_MEN_LIS_VIA"));
        oFormDialogListVia.setVisible(true);
    }//GEN-LAST:event_jmniViaActionPerformed

    private void jmniCargoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jmniCargoActionPerformed
        // TODO add your handling code here:
        FormDialogListCargo oFormDialogListCargo = new FormDialogListCargo(this, true);
        oFormDialogListCargo.setLocationRelativeTo(this);
        oFormDialogListCargo.setTitle(rbMainMenu.getString("SUB_MEN_LIS_CAR"));
        oFormDialogListCargo.setVisible(true);
    }//GEN-LAST:event_jmniCargoActionPerformed

    private void jtxtUsuarioActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jtxtUsuarioActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_jtxtUsuarioActionPerformed

    private void jmniConfiguracionGeneralActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jmniConfiguracionGeneralActionPerformed
        // TODO add your handling code here:
        FormDialogMantConfiguracion oFormDialogMantConfiguracion = new FormDialogMantConfiguracion(this, true);
        oFormDialogMantConfiguracion.setLocationRelativeTo(this);
        oFormDialogMantConfiguracion.setTitle(rbMainMenu.getString("SUB_MEN_LIS_CONF"));
        oFormDialogMantConfiguracion.setVisible(true);
    }//GEN-LAST:event_jmniConfiguracionGeneralActionPerformed

    private void jmniProcesarPermisosActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jmniProcesarPermisosActionPerformed
        // TODO add your handling code here:
        FormDialogMantProcesarPermisos oFormDialogMantProcesarPermisos = new FormDialogMantProcesarPermisos(this, true);
        oFormDialogMantProcesarPermisos.setLocationRelativeTo(this);
        oFormDialogMantProcesarPermisos.setTitle(rbMainMenu.getString("SUB_MEN_MAN_PERM"));
        oFormDialogMantProcesarPermisos.setVisible(true);
    }//GEN-LAST:event_jmniProcesarPermisosActionPerformed

    private void jmniRolesActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jmniRolesActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_jmniRolesActionPerformed

    private void jmniAcercaSistemaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jmniAcercaSistemaActionPerformed
        // TODO add your handling code here:
        FormDialogInformacion oFormDialogInformacion = new FormDialogInformacion(this, true);
        oFormDialogInformacion.setLocationRelativeTo(this);
        oFormDialogInformacion.setTitle(rbMainMenu.getString("SUB_MEN_SEG_INF"));
        oFormDialogInformacion.setVisible(true);
    }//GEN-LAST:event_jmniAcercaSistemaActionPerformed

    private void jMenuItem1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem1ActionPerformed
        // TODO add your handling code here:
        FormDialogPermisosPorDia oFormDialogPermisosPorDia = new FormDialogPermisosPorDia(this, true);
        oFormDialogPermisosPorDia.setLocationRelativeTo(this);
        oFormDialogPermisosPorDia.setTitle(rbMainMenu.getString("SUB_MEN_LIS_CONF"));
        oFormDialogPermisosPorDia.setVisible(true);
    }//GEN-LAST:event_jMenuItem1ActionPerformed

    private void jmniRptAsistenciasActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jmniRptAsistenciasActionPerformed
        // TODO add your handling code here:
        FormDialogRepAsistencias oFormDialogRepAsistencias = new FormDialogRepAsistencias(this, true);
        oFormDialogRepAsistencias.setLocationRelativeTo(this);
        oFormDialogRepAsistencias.setTitle(rbMainMenu.getString("SUB_MEN_LIS_CONF"));
        oFormDialogRepAsistencias.setVisible(true);
    }//GEN-LAST:event_jmniRptAsistenciasActionPerformed

    private void jmniRptPermisosVacacionesActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jmniRptPermisosVacacionesActionPerformed
        // TODO add your handling code here:
        FormDialogRepPermisos oFormDialogRepPermisos = new FormDialogRepPermisos(this, true);
        oFormDialogRepPermisos.setLocationRelativeTo(this);
        oFormDialogRepPermisos.setTitle(rbMainMenu.getString("SUB_MEN_LIS_CONF"));
        oFormDialogRepPermisos.setVisible(true);
    }//GEN-LAST:event_jmniRptPermisosVacacionesActionPerformed

    private void jmniControlAsistenciaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jmniControlAsistenciaActionPerformed
        // TODO add your handling code here: FormDialogControlAsistencias
        FormDialogControlAsistencias oFormDialogControlAsistencias = new FormDialogControlAsistencias(this, true);
        oFormDialogControlAsistencias.setLocationRelativeTo(this);
        oFormDialogControlAsistencias.setTitle(rbMainMenu.getString("SUB_MEN_LIS_CONF"));
        oFormDialogControlAsistencias.setVisible(true);
    }//GEN-LAST:event_jmniControlAsistenciaActionPerformed

    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        /* Set the Nimbus look and feel */
        //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
        /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
         * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html 
         */
        try {
//            for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
//                if ("Nimbus".equals(info.getName())) {
//                    javax.swing.UIManager.setLookAndFeel(info.getClassName());
//                    break;
//                }
//            }
            UIManager.setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsLookAndFeel");

        } catch (Exception ex) {
            java.util.logging.Logger.getLogger(FormPrincipal.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        }
        //</editor-fold>

        /* Create and display the form */
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                new FormPrincipal().setVisible(false);
            }
        });
    }
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel10;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JLabel jLabel7;
    private javax.swing.JMenu jMenu1;
    private javax.swing.JMenu jMenu2;
    private javax.swing.JMenuItem jMenuItem1;
    private javax.swing.JMenuItem jMenuItem2;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JPanel jPanel3;
    private javax.swing.JPopupMenu.Separator jSeparator1;
    private javax.swing.JPopupMenu.Separator jSeparator3;
    private javax.swing.JToolBar.Separator jSeparator4;
    private javax.swing.JSeparator jSeparator5;
    private javax.swing.JSeparator jSeparator6;
    private javax.swing.JPopupMenu.Separator jSeparator7;
    private javax.swing.JPopupMenu.Separator jSeparator8;
    private javax.swing.JButton jbmbarSalir;
    private javax.swing.JButton jbtnIniciarSesion;
    private javax.swing.JDesktopPane jdesktopPrincipal;
    private javax.swing.JDialog jformDialogLogin;
    private javax.swing.JLabel jlblEmpresaPrincipal;
    private javax.swing.JLabel jlblFechaHoraPrincipal;
    private javax.swing.JLabel jlblUsuarioPrincipal;
    public static javax.swing.JMenuBar jmenubarPrincipal;
    private javax.swing.JMenu jmnMaestros;
    private javax.swing.JMenu jmnOpciones;
    private javax.swing.JMenu jmnPersonal;
    private javax.swing.JMenu jmnReportes;
    private javax.swing.JMenu jmnSeguridad;
    private javax.swing.JMenuItem jmniAcercaSistema;
    private javax.swing.JMenuItem jmniArea;
    private javax.swing.JMenuItem jmniCambioClave;
    private javax.swing.JMenuItem jmniCargo;
    private javax.swing.JMenuItem jmniConfiguracionGeneral;
    private javax.swing.JMenuItem jmniControlAsistencia;
    private javax.swing.JMenuItem jmniDiaFeriado;
    private javax.swing.JMenuItem jmniHorario;
    private javax.swing.JMenuItem jmniInterfazAsistencia;
    private javax.swing.JMenuItem jmniPersonal;
    private javax.swing.JMenuItem jmniProcesarPermisos;
    private javax.swing.JMenuItem jmniRoles;
    private javax.swing.JMenuItem jmniRptAsistencias;
    private javax.swing.JMenuItem jmniRptPermisosVacaciones;
    private javax.swing.JMenuItem jmniSalir;
    private javax.swing.JMenuItem jmniUsuarios;
    private javax.swing.JMenuItem jmniVia;
    private javax.swing.JMenuItem jmniZona;
    private javax.swing.JMenu jsmnRolesPermisos;
    private javax.swing.JMenu jsmnUsuariosClaves;
    private javax.swing.JToolBar jtbarAbajo;
    private javax.swing.JToolBar jtbarArriba;
    private javax.swing.JPasswordField jtxtClave;
    private javax.swing.JTextField jtxtUsuario;
    // End of variables declaration//GEN-END:variables

    @Override
    public Image getIconImage() {
        URL url = null;
        try {
            url = new URL(getClass().getResource("/com/jsysacc/asistencia/view/resources/icons/icono.png").toString());
        } catch (MalformedURLException ex) {
            Logger.getLogger(FormPrincipal.class.getName()).log(Level.SEVERE, null, ex);
        }
        Image retValue = Toolkit.getDefaultToolkit().getImage(url);
        return retValue;
    }

    @Override
    public void run() {
        Thread ct = Thread.currentThread();
        while (ct == h1) {
            calcula();
            jlblFechaHoraPrincipal.setText(fecha + " " + hora + ":" + minutos + ":" + segundos + " " + ampm);
            if (FormDialogRegistroAsistencia.jlblHora != null) {
                FormDialogRegistroAsistencia.jlblHora.setText(hora + ":" + minutos + ":" + segundos + " " + ampm);
                FormDialogRegistroAsistencia.hora = hora;
                FormDialogRegistroAsistencia.minutos = minutos;
                FormDialogRegistroAsistencia.segundos = segundos;
                FormDialogRegistroAsistencia.ampm = ampm;
                FormDialogRegistroAsistencia.fechaSis = fechaSis;

            }

            try {
                Thread.sleep(1000);
            } catch (InterruptedException e) {
            }

        }
    }

    public void calcula() {
        Calendar calendario = new GregorianCalendar();
        Date fechaHoraActual = null;
        DateTime fechaSistema = null;
        try {
            fechaSistema = logic.getNow();
            fechaHoraActual = fechaSistema.toDate();
        } catch (Exception ex) {
            Logger.getLogger(FormPrincipal.class.getName()).log(Level.SEVERE, null, ex);
        }
        fechaSis = fechaSistema;
        calendario.setTime(fechaHoraActual);
        ampm = calendario.get(Calendar.AM_PM) == Calendar.AM ? "AM" : "PM";
        if (ampm.equals("PM")) {
            int h = calendario.get(Calendar.HOUR_OF_DAY) - 12;
            hora = h > 9 ? "" + h : "0" + h;
        } else {
            hora = calendario.get(Calendar.HOUR_OF_DAY) > 9 ? "" + calendario.get(Calendar.HOUR_OF_DAY) : "0" + calendario.get(Calendar.HOUR_OF_DAY);
        }
        minutos = calendario.get(Calendar.MINUTE) > 9 ? "" + calendario.get(Calendar.MINUTE) : "0" + calendario.get(Calendar.MINUTE);
        segundos = calendario.get(Calendar.SECOND) > 9 ? "" + calendario.get(Calendar.SECOND) : "0" + calendario.get(Calendar.SECOND);
        fecha = fechaSistema.toString("'Hoy es' EEEEEEEEE dd 'de' MMMMM 'de' yyyy");
    }

    @Override
    public boolean hayErroresInput() {
        throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
    }

    @Override
    public void getEntity() {
        throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
    }

    @Override
    public void setEntity(Object entity) {
        throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
    }

    @Override
    public void initMaster() {
        h1 = new Thread(this);
        h1.start();
    }
}
